<include file="__THEME__/public_header" />
<div class="content">
	<div class="wrap">
    	<div class="con_side">
        	<ul class="nav">
            	<li><a href="{:U('admin/Report/show_report_screen')}">市区级报告</a></li>
                <li><a href="{:U('admin/Report/show_garden_reports')}">园级报告</a></li>
                <li><a href="{:U('admin/Report/show_report_evaluate')}">评价报告</a></li>
                <li class="cursor"><a href="{:U('admin/Report/health_advice')}">体质改善方法</a></li>
            </ul>
        </div>
        <div class="con_main">
        	<div class="con_tit">
            	<ul class="con_link">
                    <li><a href="javascript:;">筛选</a></li>
                    <li class="on"><a href="{:U('admin/Report/add_health_advice')}">添加</a></li>
                </ul>
            </div>
            <div class="con_box">
            	<ul class="slect_list2">
                    <li>
                        <div class="txt">锻炼类型：</div>
                        <div class="inp">
                            <select id="advice_type">
                                <option value="">------请选择------</option>
                                <option  value="1">速度</option>
                                <option  value="2">上肢</option>
                                <option  value="3">下肢</option>
                                <option  value="4">平衡</option>
                                <option  value="5">灵敏</option>
                                <option  value="6">柔韧</option>
                            </select>
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                    <li>
                        <div class="txt">改善名称：</div>
                        <div class="inp">
                            <input type="text" id="advice_name" style="height:30px;">
                        </div>
                    </li>
                </ul>
                <ul class="slect_list2">
                    <li>
                        <div class="txt">上传改善方法：</div>
                        <div class="inp" style="width:500px;height:200px;margin: -40px 0px 0px 90px;" id="msg">
                            <img src="__ROOT__/apps/public/_static/image/default.png" id="cover_yulan" style="width:370px;height:210px;"/>
                        </div>&nbsp;&nbsp;
                        <form name="uploadFrom" id="uploadFrom" action="{:U('admin/Resource/doAddImg')}" method="post"  target="tarframe" enctype="multipart/form-data">
                            <input type="file" style="margin: -190px 0px 0px 465px;" name="cover" id="upload_file" onchange="handleFiles(this)">
                        </form>
                        <iframe src=""  width="0" height="0" style="display:none;" name="tarframe"></iframe>
                        <input name="old_cover" type="hidden" value='{$coverId}'>
                    </li>
                </ul>
            	<div class="action_link tc small">
                    <input type="hidden" id="attach_id">
                	<a class="save" href="javascript:addHealthAdvice();">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    window.URL = window.URL || window.webkitURL;
    var fileElem = document.getElementById("cover");
    function stopSend(url,id){
     if(url){
        $('#cover_yulan').attr('src',url);
        $("#attach_id").val(id);
     }else{
      alert("上传失败");
     }
    }
    function handleFiles(obj) {
      $("#uploadFrom").submit();
    }
    function addHealthAdvice(){
        var advice_name=$("#advice_name").val();
        var attach_id=$("#attach_id").val();
        var advice_type=$("#advice_type").val();
        if(advice_name==""){
            alert("改善名称不能为空");
            return;
        }
        if(attach_id==""){
            alert("请上传图片");
            return;
        }
        if(advice_type==""){
            alert("请选择类型");
            return;
        }
        $.ajax({
            type: "POST",
            url:"{:U('admin/Report/addHealthAdvice')}",
            data:"advice_name="+advice_name+"&attach_id="+attach_id+"&advice_type="+advice_type,
            dataType:"text",
            success:function(data){
             if(isNaN(data)){
                  alert(data);
              }else{
                window.location.href="{:U('admin/Report/health_advice')}";
              }
            }
        });
    }
    //筛选条件
    function select_filter(){
      var advice_type=$("#advice_type").val();
      window.location.href="{:U('admin/Report/health_advice')}"+"&advice_type="+advice_type;
    }
</script>
<include file="__THEME__/public_footer" />